/**************************************************************************
 * @doc EMV
 * @module emvfuncs.h |  
 * Header file for handling the EMV functionality
 *
 * Product     :   SoftPay 2000 (Global Payment Methodology).
 * <nl>Developer   :   
 * <nl>Notes       :
 *
 * @head3 EMV Functions |
 * @index | EMV
 * @end
 *
 * Copyright (c) 1996-2000 by VeriFone Inc. All rights reserved.
 * 
 * No part of this software may be used, stored, compiled, reproduced,
 * modified, transcribed, translated, transmitted, or transferred, in any form 
 * or by any means whether electronic, mechanical, magnetic, optical, 
 * or otherwise, without the express prior written permission of VeriFone, Inc.
 *
 * Revision History
 * ------------------------------------------------------------------------
 $log:  $
 * ------------------------------------------------------------------------
 ********************************************************************************/

#ifndef EMVFUNCS_H
#define EMVFUNCS_H


/* Values for chip status flag */
//#define NOT_USING_CHIP       -1
//#define EMV_CARD             -2
//#define EMV_EASY_ENTRY_CARD  -3

/* Values for authorised/declined flag */
#define EMV_TRAN_AUTHORISED   -1
#define EMV_TRAN_DECLINED     -2
#define EMV_TRAN_REFERRED     -3
#define EMV_TRAN_CANCELLED    -4

/* Values for Online Failed flag */
#define EMV_COMMS_FAILURE     -1
#define EMV_COMMS_OK          -2

/* Values for EMV card decision flag */
#define EMV_GO_ONLINE      -1
#define EMV_OFFLINE_AUTH   -2
#define EMV_DECLINE        -3
#define EMV_VOICE_REFERRAL -4

/* Values for Field IDs in batch flexi record */
#define FID_EMV_AIP                         0x6301
#define FID_EMV_ATC                         0x6302
#define FID_EMV_AUC                         0x6303
#define FID_EMV_CID                         0x6304
#define FID_EMV_CVM_LIST                    0x6305
#define FID_EMV_CVM_RESULTS                 0x6306
#define FID_EMV_IAC_DEFAULT                 0x6307
#define FID_EMV_IAC_DENIAL                  0x6308
#define FID_EMV_IAC_ONLINE                  0x6309
#define FID_EMV_ISSUER_APP_DATA             0x630A
#define FID_EMV_ISSUER_SCRIPT_RESULTS       0x630B
#define FID_EMV_TERM_CAPABILITIES           0x630C
#define FID_EMV_TERM_TYPE                   0x630D
#define FID_EMV_TVR                         0x630E
#define FID_EMV_APP_CRYPTOGRAM              0x630F
#define FID_EMV_UNPREDICT_NUMBER            0x6310

//jrd  AMEX 09272005
#define FID_AMEX_EMV_AID					0x6311
#define FID_AMEX_EMV_APP_LABEL                    0x6312

char*	szGetPTID(char *ptid);
int inAddEMVFunctions(void);
int  inEMVAddAmountToPool(TRANSACTION_OBJECT *pobTran);
int  inEMVGetBaseAmount(TRANSACTION_OBJECT *pobTran);

int inEMVInit(TRANSACTION_OBJECT *pobTran);
int inEMVTransInit(TRANSACTION_OBJECT *pobTran);
int inEMVRemoveCard(TRANSACTION_OBJECT *pobTran);
int inEMVPRandTRM(TRANSACTION_OBJECT *pobTran);
int inEMVCardholderVerification(TRANSACTION_OBJECT *pobTran);
int inEMVFirstGenerateAC(TRANSACTION_OBJECT *pobTran);
int inEMVUseHostDataFlow(TRANSACTION_OBJECT *pobTran);
int	inEMVParseEasyEntryTrack2(TRANSACTION_OBJECT *pobTran, char *);
int inEMVGetCardConfig(TRANSACTION_OBJECT *pobTran);
int inEMVDataAuthentication(TRANSACTION_OBJECT *pobTran);

void vdEMVSetICCReadFailure(unsigned);
int  inEMVGetICCReadFailure(void);
void vdDisplayFallbackMsg(TRANSACTION_OBJECT *pobTran);
int  inDisplayOverrideChipScrn(void);
int inEMVGetFallbackToMSR(void);
void vdEMVSetFallbackToMSR(unsigned fFlag);
int inValidateEMVServiceCode(TRANSACTION_OBJECT *pobTran, char *szServiceCode);
int inEMVCheckFallback(TRANSACTION_OBJECT *pobTran);
int	inDefaultHostEasyEntry (TRANSACTION_OBJECT *pobTran);
int inEMVValidateICCCard (TRANSACTION_OBJECT *pobTran);
int inEMVDemo(TRANSACTION_OBJECT *pobTran);
int inEMVEuropaySpecificTests(TRANSACTION_OBJECT *pobTran);
int inEMVSetOffline (TRANSACTION_OBJECT *pobTran);
//unsigned short usEMVChooseApplication(int inAutoSelect, srAIDList *psrTerminalAIDList, srAIDList *psrCandidateList);
int inEMVValidateTrack2Data(unsigned char *, int, unsigned char *, int, unsigned char *, int, unsigned char *);
int inEMVHandleSplitSales (TRANSACTION_OBJECT *pobTran);
int inEMVPrepareBatch(TRANSACTION_OBJECT *pobTran);
int inEMVGetFloorLimitUsed(void);
void vdEMVSetFloorLimitUsed(unsigned);
int inEMVPrepareBatchFlow(TRANSACTION_OBJECT *pobTran);
int inEMVCardholderVerificationEnvelope(TRANSACTION_OBJECT *pobTran);
int inEMVResetPCT(TRANSACTION_OBJECT *pobTran);

#endif

